package com.ruoyi.web.controller.task;

import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.utils.StringUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.task.VsDramasTask;
import com.ruoyi.system.service.task.IVsDramasTaskService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
/**
 * This file is part of 南阳迈特网络科技有限公司.
 * @company  南阳迈特网络科技有限公司
 * @link     https://www.nymaite.com
 * @document https://product.nymaite.cn
 * @contact  service@nymaite.com
 * @author nymaite
 */
/**
 * 任务Controller
 * 
 * @author zzx
 * @date 2024-04-27
 */
@Api(tags = "任务")
@RestController
@RequestMapping("/task/task")
public class VsDramasTaskController extends BaseController
{
    @Autowired
    private IVsDramasTaskService vsDramasTaskService;

    /**
     * 查询任务列表
     */
    @ApiOperation("查询任务列表")
    @ApiImplicitParam(name = "langId", value = "langId", required=true)
    @GetMapping("/list")
    public TableDataInfo list(VsDramasTask vsDramasTask, HttpServletRequest request)
    {
        startPage();
        if (!StringUtils.isEmpty(request.getHeader("Lang-Id"))) {
            Integer integer = Integer.valueOf(request.getHeader("Lang-Id"));
            vsDramasTask.setLangId(integer);
        }
        List<VsDramasTask> list = vsDramasTaskService.selectVsDramasTaskList(vsDramasTask);
        return getDataTable(list);
    }

    /**
     * 导出任务列表
     */
//    @ApiOperation("导出任务列表")
    @Log(title = "任务", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, VsDramasTask vsDramasTask)
    {
        List<VsDramasTask> list = vsDramasTaskService.selectVsDramasTaskList(vsDramasTask);
        ExcelUtil<VsDramasTask> util = new ExcelUtil<VsDramasTask>(VsDramasTask.class);
        util.exportExcel(response, list, "任务数据");
    }

    /**
     * 获取任务详细信息
     */
    @ApiOperation("获取任务详细信息")
    @ApiImplicitParam(name = "id", value = "任务id", required=true)
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(vsDramasTaskService.selectVsDramasTaskById(id));
    }

    /**
     * 新增任务
     */
//    @ApiOperation("新增任务")
    @Log(title = "任务", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody VsDramasTask vsDramasTask)
    {
        return toAjax(vsDramasTaskService.insertVsDramasTask(vsDramasTask));
    }

    /**
     * 修改任务
     */
//    @ApiOperation("修改任务")
    @Log(title = "任务", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody VsDramasTask vsDramasTask)
    {
        return toAjax(vsDramasTaskService.updateVsDramasTask(vsDramasTask));
    }

    /**
     * 删除任务
     */
//    @ApiOperation("删除任务")
    @Log(title = "任务", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(vsDramasTaskService.deleteVsDramasTaskByIds(ids));
    }
}
